using EmitMapper;
using EmitMapper.MappingConfiguration;
using GeYiHome.Bussines.BusinesMapping.Adapters;

namespace GeYiHome.Bussines.BusinesMapping
{
    public class Mapping<TS, TD> : TypeMapConfigurationBase<TS, TD> where TS : class where TD : class, new()
    {
        private ObjectsMapper<TS, TD> _mapper;

        protected override void BeforeMap(ref TS source)
        {
            _mapper = ObjectMapperManager.DefaultInstance.GetMapper<TS, TD>();
        }

        protected override void AfterMap(ref TD target, params object[] moreSources)
        {
        }

        protected override TD Map(TS source)
        {
            return _mapper.Map(source);
        }
    }
}
